package c_leetcode.a_160_intersection_tow_linked;

import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author He Kuntao
 * @since 2025/3/13 9:20
 */
@Data
@NoArgsConstructor
public class ListNode {
    /**
     * 链表节点数据
     */
    String val;

    /**
     * 下一个节点
     */
    ListNode next;

    public ListNode(String val) {
        this.val = val;
    }


    public static ListNode[] createListNode() {
        // a1 -> a2 -> c1 -> c2 -> c3
        ListNode a1 = new ListNode("a1");
        a1.next = new ListNode("a2");
        a1.next.next = new ListNode("c1");
        a1.next.next.next = new ListNode("c2");
        a1.next.next.next.next = new ListNode("c3");

        // b1 -> b2 -> b3 -> c1 -> c2 -> c3
        ListNode b1 = new ListNode("b1");
        b1.next = new ListNode("b2");
        b1.next.next = new ListNode("b3");
        b1.next.next.next = a1.next.next;
        return new ListNode[]{a1, b1};
    }

    public static void printLiked(ListNode headA, ListNode headB) {
        while (headA != null) {
            System.out.print(headA.val + "->");
            headA = headA.next;
        }
        System.out.println("null");
        while (headB != null) {
            System.out.print(headB.val + "->");
            headB = headB.next;
        }
        System.out.println("null");
    }
}
